
import java.util.Scanner;
public class Hdu1062 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  while(sc.hasNext()){
  int n = Integer.valueOf(sc.nextLine());
  for (int i = 0; i < n; i++) {
   String a = sc.nextLine();
   String[] b = a.split(" ");
   // System.out.println(b.length);
   for (int j = 0; j < b.length; j++) {
    char[] c = b[j].toCharArray();
    for (int k = 0; k < c.length; k++) {
     System.out.print(c[c.length - k - 1]);
    }
    if (j != b.length - 1)
     System.out.print(" ");
   }
   
    System.out.println();
  }
  }
 }
}